<?php 
	require_once './utils/DBUtil.php';
?>
<html>
<head>
<title>Design Page</title>
  <link href="./css/header.css" rel="stylesheet">
  <link href="./css/design.css" rel="stylesheet">
</head>
<body>
<div class="pagetitle"><h1>Database Design and Implementation</h1></div>
<div id="nav">
	<a href="./design.php">Database Design and Implementation</a>
	<a href="./index.php">Search</a>
</div>
<div class="desc">
	<h2>Scenario Description</h2>
	<p>The scenario of my site is to show various musics of different singers. Every music belongs to a singer and a singer can have many musics. Every music belongs to multiple genres and every genre has multiple musics. We can search the musics by different conditions and we can see the details at the detail page.</p>
</div>
<div class="clsDiagram">
	<h2>Class Diagram</h2>
	<img alt="Class Diagram" src="./img/classDiagram.png">
</div>
<div class="phsic">
	<h2>Physical Data Model</h2>
	<img alt="Physical Data Model" src="./img/phiscDiagram.png">
</div>
<div class="tables">
	<h2>Database Tables</h2>
	<?php
		$con = getConn();
		$con->exec("set names utf8"); 
		foreach($con->query('show tables') as $row) {
		        ?>
		        <h3><?php echo $row[0]?></h3>
		        <table>
		        	<tr>
		        	<?php
		        		$i = 0;
		        		foreach ($con->query("DESCRIBE ".$row[0]) as $tabletitle) {
		        			$i++;
		        			?>
		        			
				        		<th><?php echo $tabletitle[0]?></th>
				        	
		        			<?php 
		        		}
		        	?>
		        	</tr>
		        	<?php 
		        		foreach($con->query('select * from '.$row[0]) as $tablerow) {
		        			?>
		        			<tr>
		        				<?php 
		        					for($ii=0;$ii<$i;$ii++){
		        						?>
		        						<td><?php echo $tablerow[$ii]?></td>
		        						<?php 
		        					}
		        				?>
		        			</tr>
		        			<?php 
		        		}
		        	?>
		        	
		        </table>
		        <?php 
		}
		$con = null;
	?>
	<p>Descriptions of genres taken from wikipedia.org (https://en.wikipedia.org/wiki/List_of_popular_music_genres)</p>
</div>
</body>
</html>